package com.translate.web.api.controller;

import java.util.List;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.param.impl.IdParam;
import com.response.vo.ResponseModel;
import com.translate.vo.ServiceManagerVO;
import com.translate.web.service.IServiceManagerService;

@RestController
@RequestMapping("serviceManager")
public class ServiceManagerController {
	private IServiceManagerService service;


	public ServiceManagerController(IServiceManagerService service) {
		this.service = service;
	}


	/**
	 * 服务介绍列表
	 * @param param
	 * @return
	 */
	@GetMapping("/listServices")
	public ResponseModel<List<ServiceManagerVO>> listServices() {
		
		return ResponseModel.<List<ServiceManagerVO>>success(
				this.service.getListFromCache(ServiceManagerVO.class));
	}
	
	/**
	 * 服务文章
	 * @param param
	 * @return
	 */
	@PostMapping("/getArticle")
	public ResponseModel<ServiceManagerVO> getArticleById(@RequestBody @Validated IdParam param) {
		
		return ResponseModel.<ServiceManagerVO>success(this.service.getArticleById(param.getId(), ServiceManagerVO.class));
	}
	
}